import book.BookList;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static User Login(){
        Scanner s = new Scanner(System.in);
        System.out.println("请输入您的姓名：");
        String name = s.nextLine();
        System.out.println("请选择您的权限(1.管理员  2.普通用户)：");
        int power = s.nextInt();
        User user = null;
        if(power == 1){
            //管理员
            user = new AdminUser(name, power);
        }else if(power == 2){
            //普通用户
            user = new NormalUser(name, power);
        }else{
            System.out.println("输入错误");
        }
        return user;
    }
    public static void main(String[] args) {
        BookList bookList = new BookList();
        //登录
        User user = Login();
        //打印目录
        while(true){
            int choice = user.menu();
            user.doAction(choice, bookList);
        }
    }
}